//
//  WYResourceCell.m
//  CirclePush
//
//  Created by admin on 2018/5/19.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYResourceCell.h"

@interface WYResourceCell()

@property (strong, nonatomic) IBOutlet UIButton *mediaBtn;


@end

@implementation WYResourceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.backgroundColor = [UIColor whiteColor];
    
    [self.mediaBtn setBorderWithWidth:kLineHeight andColor:[UIColor blueColor]];
    [self.mediaBtn setCornerRadius:5.0f];
    
    
//    NSString *content = @"<p>\n\t媒体资源介绍<span>媒体资源介绍</span><span>媒体资源介绍</span><span>媒体资源介绍</span><span>媒体资源介绍</span> \n</p>\n<p style=\"text-align:center;\">\n\t<span><span>媒体资源介绍</span><span>媒体资源介绍</span></span> \n</p>\n<p style=\"text-align:center;\">\n\t<span><img src=\"http://47.92.78.4:8086/MySpringUpload/upload/1526625102270.jpg\" alt=\"\" /><br />\n</span> \n</p>";
//    [self.webView loadHTMLString:content baseURL:nil];
    
    
    
    // Initialization code
    
    
    
    WKWebViewConfiguration *confifg = [[WKWebViewConfiguration alloc] init];
    confifg.selectionGranularity = WKSelectionGranularityCharacter;
    _webView = [[WKWebView alloc] initWithFrame:CGRectMake(14, 0, kScreenWidth - 28, 1) configuration:confifg];
//    _webView setconfi
    
    
    //    _webView.scalesPageToFit = NO;
    _webView.scrollView.scrollEnabled=NO;
    _webView.userInteractionEnabled = NO;
    _webView.opaque = NO;
    _webView.scrollView.bounces=NO;
    _webView.backgroundColor=[UIColor whiteColor];
    _webView.scrollView.decelerationRate=UIScrollViewDecelerationRateNormal;
    [self.contentView addSubview:_webView];
}
-(void)setHtmlString:(NSString *)htmlString
{
  //  _htmlString = htmlString;
   // [self.webView loadHTMLString:htmlString baseURL:nil];
    
    if (!_htmlString) {
        _htmlString = htmlString;
        if (_htmlString.length>0) {
            
            NSString *zhengtibinchulai = [NSString stringWithFormat:@"<style>p{width: 85%%;box-sizing: border-box;margin:0 auto;} img{display:block;width:100%%;}</style><meta content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;\" name=\"viewport\" />%@<div id=\"testDiv\" style = \"height:1px; width:1px\"></div>",_htmlString];
            NSLog(@"%@",zhengtibinchulai);
            
            [_webView loadHTMLString:[NSString stringWithFormat:@"<style>p{width: 85%%;box-sizing: border-box;margin:0 auto;} img{display:block;width:100%%;}</style><meta content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;\" name=\"viewport\" />%@<div id=\"testDiv\" style = \"height:1px; width:1px\"></div>",_htmlString] baseURL:nil];
            
            
            
        }
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)getMediaMessage:(id)sender {
    if ([self.delegate respondsToSelector:@selector(clickGetPPTBtn)]) {
        [self.delegate clickGetPPTBtn];
    }
    
    
    
}




@end
